package com.martian.service.impl;

import com.martian.mapper.QuestionMapper;
import com.martian.pojo.dto.MovieQuestionsDto;
import com.martian.pojo.form.NewMovieQuestionFrom;
import com.martian.pojo.form.UserAnswerForm;
import com.martian.service.QuestionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author martian
 * @version V1.0.0
 * @Description
 * @date 2023-08-14 15:55
 */
@Service
public class QuestionServiceImpl implements QuestionService {
    @Resource
    private QuestionMapper questionMapper;
    @Override
    public List<MovieQuestionsDto> getMovieQuestions(Integer movieId,Integer num) {
        return questionMapper.getMovieQuestions(movieId,num);
    }

    @Override
    public Integer getRatingQualification(Integer userId, Integer movieId) {
        return questionMapper.getRatingQualification(userId,movieId);
    }

    @Override
    public Integer insertMovieQuestions(NewMovieQuestionFrom newMovieQuestionFrom) {
        questionMapper.insertMovieQuestions(newMovieQuestionFrom);
        return questionMapper.selectQuestions();
    }

    @Override
    public void insertUserAnswer(Integer userId,UserAnswerForm userAnswerForm) {
        questionMapper.insertUserAnswer(userId,userAnswerForm);
    }

    @Override
    public void updateUserAnswer(UserAnswerForm userAnswerForm) {
        questionMapper.updateUserAnswer(userAnswerForm);
    }
}
